<?php

$is_command = php_sapi_name() != 'cli' ? false : true;

if (!$is_command) {
    exit('不是命令行');
}

date_default_timezone_set('PRC');

ini_set('display_errors', 0);
ini_set('log_errors', 1);
set_time_limit(0);
ini_set('memory_limit','512M');
error_reporting(E_ALL & ~E_NOTICE);

//自动加载
require("config.php");
require(WEBROOT.DS.'lib'.DS.'autoload.php');

require(WEBROOT.DS.'lib/PHPExcel'.DS.'PHPExcel.php');
require(WEBROOT.DS.'lib/PHPExcel'.DS.'PHPExcel'.DS.'IOFactory.php');

require(WEBROOT.DS.'Controller'.DS.'export.class.php');

$Export = new Export();

// d 记录d
$parms = getopt("d:");

if (empty($parms['d'])) {
    exit('参数错误');
}

$id = $parms['d'];
$Export->getmgData($id);
echo 2222;exit;

echo $id;exit;

$table = 't_areaex';
$sheetObj = null;   //导出Excel文件对象

//获取记录信息
$mgdb = new mgdb();
$info = $mgdb->where(array('_id' => new MongoId($id)))->get('download');

if (empty($info)) {
    exit('没有记录');
}

$info = current($info);

$pdo = new \PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);

$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);

$pageSize = 200; //每个文件多少条记录
$total = getTotal();    //总符合记录数

$where = [];
$loopNum = ceil($total/$pageSize);
$loopNum = 1;

$savePath = getSavePath($info['eid']);  //保存路径
$tarPath = dirname($savePath);  //打包路径
